<include file="Public/head" xmlns="http://www.w3.org/1999/html"/>
<include file="Public/common_header" />
<link type="text/css" rel="stylesheet" href="{:get_style_cdnurl()}paimai/yunying/css/cashier.css"/>
<meta charset="UTF-8"/>
<script type="text/javascript">
    $(function(){
        $("input").placeholder();
        if (navigator.userAgent.indexOf("Safari") > -1) {
            $("input").css("lineHeight","normal !important");
        };
    });
</script>
<div class="mian">
    <include file="Public/sidebar" menu="hdgl.cchd"  />
    <div class="mianR">
        <div class="live-cont">
            <div class="live-seach">
                <form id="search_form" action="/SceneActivity/activity_list" method="get">
                    <input type="hidden" id="p" name='p' value="" />
                    <ul class="clearfix">
                        <li>
                            <select id="type" name="type">
                                <option>请选择活动类型</option>
                                <option value="1">补贴减免</option>
                            </select>
                        </li>
                        <li>
                            <select id="branch_id" name="branch_id">
                                <option>请选择分公司</option>
                                <foreach name="arr.bc_list" key="key" item="bc_name">
                                    <option value="{$key}">{$bc_name}</option>
                                </foreach>
                            </select>
                            <script>
                                var branch_id = "{:I('get.branch_id')}";
                                var type = "{:I('get.type')}";
                                if(branch_id){
                                    $("#branch_id").val(branch_id).attr("select","selected");
                                }
                                if(type){
                                    $("#type").val(type).attr("select","selected");
                                }
                            </script>
                        </li>
                        <li><span>时间：</span>
                            <input type="text" id="demoText2" name="starttime" class="live-time" value="{:I('get.starttime')}" placeholder="活动开始时间" readonly="">
                            <i class="time-xian"></i>
                            <input type="text" id="demoText3" name="endtime" class="live-time" value="{:I('get.endtime')}" placeholder="活动结束时间" readonly="">
                        </li>
                        <li><input type="button" value="搜索" onclick="search('#search_form')"/></li>
                    </ul>
                <!--</form>-->
                <a href="/SceneActivity/add" class="add-live">添加活动</a>
            </div>
            <table class="table">
                <thead>
                    <tr>
                        <th width="10%">活动名称</th>
                        <th width="10%">活动类型</th>
                        <th width="10%">所属分公司</th>
                        <th width="13%">创建时间</th>
                        <th width="26%">活动时间</th>
                        <th width="8%">活动状态</th>
                        <th width="10%">减免规则</th>
                        <th width="15%">操作</th>
                    </tr>
                </thead>
                <tbody>
                    <foreach name="arr.list" item="data">
                        <tr>
                            <td>{$data.name}</td>
                            <td>{$data.type}</td>
                            <td>{$data.branch_name}</td>
                            <td>{$data.createtime}</td>
                            <td>
                                {$data.starttime} - {$data.endtime}
                            </td>
                            <td><?php echo $data['status'] == 1? '启用': '已禁用'; ?></td>
                            <td>{$data.rules_type}</td>
                            <td>
                                <a href="/SceneActivity/activity_detail/activity_id/{$data.id}/act/view">查看</a>
                                <if condition="$data.is_edite eq 1">
                                    <a href="/SceneActivity/edite/activity_id/{$data.id}">修改</a>
                                <else/>
                                    <a href="javascript:" class="ash-grey">修改</a>
                                </if>

                                <if condition="$data.status eq '0'">
                                    <!--<a href="/SceneActivity/activity_detail/activity_id/{$data.id}/act/enable">启用</a>-->
                                <else/>
                                    <a href="/SceneActivity/activity_detail/activity_id/{$data.id}/act/disable">禁用</a>
                                    <!--<a href="javascript:;audit('{$data.id}','disable')" class="paiche">禁用</a>-->
                                </if>
                            </td>
                        </tr>
                    </foreach>
                </tbody>
            </table>
        </div>
        <div class="pageFaye">
            <div class="pager">
                {$page_data.totalRows} 条记录 {$page_data.nowPage} /{$page_data.totalPages} 页
                <span name="first" class="disabled" style="cursor: default;">
                                <a num="{$page_data.first.num}" href="{$page_data.first.url}">首页</a>
                            </span>
                <span name="prev" class="disabled" style="cursor: default;">
                                <a num="{$page_data.prev.num}" href="{$page_data.prev.url}">上一页</a>
                            </span>
                <span name="nav_fix" style="cursor: pointer;">
                                <?php foreach ($page_data['link_page'] as $page => $link): ?>
                    <?php if($page == $p){ ?>
                    <a class="navi"  num="<?php echo $page;?>" href="<?php echo $link;?>">
                                    <font style="color:#fff"><?php echo $page;?></font>
                                </a>
                    <?php }else{?>
                    <a class="navi"  num="<?php echo $page;?>" href="<?php echo $link;?>">
                                    <?php echo $page;?>
                                </a>
                    <?php }?>
                    <?php endforeach ?>
                            </span>
                <span name="next" class="pageNext" style="cursor: pointer;"><a num="{$page_data.next.num}"  href="{$page_data.next.url}">下一页</a></span>
                <span name="last" class="pageLast" style="cursor: pointer;"><a num="{$page_data.end.num}"  href="{$page_data.end.url}">末页</a></span>
            </div>
            <div class="clear"></div>
        </div>
        <div class="clear"></div>
    </div>
    </form>
    </div>

<!---->
<div class="chenggong1">
    <span class="paidan">您确定要<i>启用</i>活动吗?</span>
    <div class="shenhei-btn">
        <input type="hidden" name="act"  value="" />
        <input type="hidden" name="activity_id"  value="" />
        <input type="button" value="确定" class="determine" />
        <input type="button" value="取消" class="cancel" />
    </div>
</div>

<script type="text/javascript">
    $('#search_form .pageFaye a').click(function () {
        $('#p').val($(this).attr('num'));
        $('#fm').submit();
        return false;
    });

    //搜索
    function search(from_id) {
        $(from_id).submit();
    }


    //审核确认窗口
    function audit(activity_id, act) {
        $('.chenggong1').css('display', 'block');
        $('.yunBei').css({'display':'block',"zIndex":999});

        $('input[name=activity_id]').val(activity_id);
        if (act == 'enable') {
            $('.paidan i').text('启用');
            $('input[name=act]').val('enable');
        } else if (act == 'disable') {
            $('.paidan i').text('禁用');
            $('input[name=act]').val('disable');
        }
    }
    //
    $(".determine").on('click', function () {
        var act = $('input[name=act]').val();
        var order_id = $('input[name=activity_id]').val();
        var param = {};
        param = {
                'act': act,
                'id': order_id,
            };

        var btn_obj = $(this);
        btn_obj.val("提交中...").attr("disabled",'disabled');
        $.post('/AuOrder/audit', param, function (data) {
            if (data.code == '200') {
                delay_alert('操作成功!');
                setTimeout(function () {
                    window.location.reload();
                }, 300);
            } else {
                shibai_alert(data.msg)
                btn_obj.val("确定").removeAttr("disabled style");
                $('.chenggong1').fadeOut();
                $('.chenggong1 textarea').remove();
            }
            $('.yunBei').css({'display':'none',"zIndex":999});
        }, 'json');
    });
    $(".cancel").on('click', function () {
        $('.chenggong1').fadeOut();
        $('.yunBei').css({'display':'none',"zIndex":999});
        $('.chenggong1 textarea').remove();
    });
</script>
<include file="Public/foot" />